import React, { useEffect ,useState} from "react";
import { _postPageData } from "./Api";
import './list.css'

const List = (value) => {

  const [pageData,setPageData] = useState({})//存储检索信息
  const [list,setList] = useState([])//存储商品列表

  useEffect(() => {
    const postReq = async () => {
      try {     
        const res = await _postPageData({
          "count": 1,
          "pageSize": 10
        });
        // console.log(res.data.list);
        setList(res.data.list);
        
      } catch (err) {
        console.log("error:", err);
      }
    };
    postReq();
  }, []);

  return (
    <>
    {list.map((item) => (
      <div className="list_div">
        <tr key={item.id}>
          <td>
          <img src={item.file} className="list_file"></img>
          </td>
        </tr>
        <tr>
          <td>火爆：{item.popularity}</td>
          <td>分类：{item.categoryId}</td>
        </tr>
        <tr>
          <td>现价：{item.currentPrice}</td>
          <td>成本：{item.cost}</td>
        </tr>
        <tr>
          <td>库存：{item.inventory}</td>
          <td>销量：{item.sales}</td>
        </tr>
        <tr>
          <td>警戒库存：{item.dangerInventory}</td>
          <td>销售单位：{item.sellingUnit}</td>
        </tr>
      </div>
    ))}
    </>
  );
};

export default List;
